package com.lzw.breezeNovel.WebAdmin.controller;


import com.lzw.breezeNovel.WebAdmin.service.ChapterService;
import com.lzw.breezeNovel.common.result.Result;
import com.lzw.breezeNovel.model.entity.pojo.novel.Chapter;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin")
@SuppressWarnings("all")
public class ChapterController {

    /**
     * 注入service
     */
    @Resource
    private ChapterService chapterService;

    /**
     * 删除章节
     */
    @DeleteMapping("/deleteChapter/{id}")
    public Result deleteChapter(@PathVariable("id") Long id){
        chapterService.deleteChapter(id);
        return Result.ok();
    }

    /**
     * 新增章节
     */
    @PostMapping("/addChapter")
    public Result deleteChapters(@RequestBody Chapter chapter){
        chapterService.addChapter(chapter);
        return Result.ok();
    }

    /**
     * 修改章节
     */
    @PutMapping("/updateChapter")
    public Result updateChapter(@RequestBody Chapter chapter){
        chapterService.updateChapter(chapter);
        return Result.ok();
    }

}
